<template>
  <div class="teacher-manage-container">
    <el-card shadow="hover">
      <div class="header">
        <h2>教师管理</h2>
        <el-input v-model="search" placeholder="搜索姓名/工号" class="search-input" clearable />
        <el-button type="primary" @click="onAdd" icon="el-icon-plus">添加教师</el-button>
      </div>
      <el-table :data="teachers" stripe border style="width: 100%; margin-top: 20px;">
        <el-table-column prop="number" label="工号" width="120" />
        <el-table-column prop="name" label="姓名" width="120" />
        <el-table-column prop="department" label="院系" width="180" />
        <el-table-column prop="email" label="邮箱" width="180" />
        <el-table-column label="操作" width="200">
          <template #default="scope">
            <el-button size="small" @click="onDetail(scope.row)" icon="el-icon-view">详情</el-button>
            <el-button size="small" type="danger" @click="onDelete(scope.row)" icon="el-icon-delete">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog v-model="dialogVisible" title="教师详情" width="500px">
      <el-form :model="form">
        <el-form-item label="工号"><el-input v-model="form.number" disabled /></el-form-item>
        <el-form-item label="姓名"><el-input v-model="form.name" /></el-form-item>
        <el-form-item label="院系"><el-input v-model="form.department" /></el-form-item>
        <el-form-item label="邮箱"><el-input v-model="form.email" /></el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible=false">关闭</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import { ref } from 'vue';
const search = ref('');
const teachers = ref([
  { number: 'T001', name: '张老师', department: '计算机学院', email: 'zhang@example.com' },
  { number: 'T002', name: '李老师', department: '管理学院', email: 'li@example.com' },
]);
const dialogVisible = ref(false);
const form = ref({});
function onAdd() { form.value = {}; dialogVisible.value = true; }
function onDetail(row) { form.value = { ...row }; dialogVisible.value = true; }
function onDelete(row) { teachers.value = teachers.value.filter(t => t.number !== row.number); }
</script>
<style scoped>
.teacher-manage-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 0;
  background: #f5f7fa;
  min-height: 100vh;
}
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
.search-input {
  width: 220px;
}
</style> 